<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;

$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$basic=$this->plugin_setting('basic');
$return['banner']=$basic['image'];
$return['basic']=$basic;

if($_RQ['op']=='main'){
	//查询分类
	$list=pdo_getall('jy_zhongchou_classify',array('uniacid'=>$_SESSION['uniacid'],'is_show'=>1),array('id','title'),'id');
	//发起人和受助人关系
	$relationlist=array('1'=>'亲属','2'=>'朋友','3'=>'同事','4'=>'同学','5'=>'邻居','6'=>'病友','7'=>'医护','8'=>'其他');
	if($list){
		foreach($list as &$row){
			$row=$row['title'];
		}
	}
	$member=pdo_get('core_members',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),array('credit1','credit2','mobile','groupid','avatar','nickname'));
	if($_RQ['postdata']){
		$postdata=get_postdata();
		if(!$postdata['title']){
			exi('标题不能为空','error');
		}
		if(!$postdata['desc']){
			exi('描述不能为空','error');
		}
		if(!$postdata['cid']){
			exi('请选择分类','error');
		}
		$insert=array(
			'uniacid'=>$_SESSION['uniacid'],
			'mid'=>$_SESSION['uid'],
			'cid'=>$postdata['cid'],
			'faname'=>$postdata['faname'],
			'phone'=>$member['mobile'],
			'shouname'=>$postdata['shouname'],
			'fa_relation'=>$postdata['rid'],
			'goalmoney'=>$postdata['goalmoney'],
			'image'=>$postdata['cailiao']['0'],
			'desc'=>$postdata['desc'],
			'title'=>$postdata['title'],
			'hospital_name'=>$postdata['hospital_name'],
			'shouchishenfenz'=>ijson_encode($postdata['shouchishenfenz']),
			'hospitalz'=>ijson_encode($postdata['hospitalz']),
			'buchong'=>ijson_encode($postdata['buchong']),
			'cailiao'=>ijson_encode($postdata['cailiao']),
			'createtime'=>TIMESTAMP
		);
		//根据分类判断是否需要审核
		$classify=pdo_get('jy_zhongchou_classify',array('uniacid'=>$_SESSION['uniacid'],'id'=>$postdata['cid']));
		if($classify['is_shenhe']==0){
			$insert['is_shenhe']==1;
			pdo_insert('jy_zhongchou_project',$insert);
		exi('发布成功','success','jy_zhongchou/myproject/main');
		}else{
			$insert['is_shenhe']==0;
			pdo_insert('jy_zhongchou_project',$insert);
		exi('发布成功，等待管理员审核','success','jy_zhongchou/myproject/main');
		}

	}
	$return['post']=array(
		
	);
	$return['post']['shouchishenfenz']=array();
	$return['post']['hospitalz']=array();
	$return['post']['buchong']=array();
	$return['post']['cailiao']=array();
	$return['list']=$list;
	$return['relationlist']=$relationlist;
	exi($return);

}